class apt_defaults {
  case $operatingsystem {
    debian: {

      $apt_dir = "/etc/apt"
      $sources_dir = "${apt_dir}/sources.list.d"

      exec { "apt-update":
        command     => "/usr/bin/apt-get update",
        refreshonly => true;
      }
      #cron { "apt-update":
      #  command => "/usr/bin/apt-get update",
      #  user    => root,
      #  hour    => 22,
      #  minute  => 0;
      #}
      # I don't want kernel upgrades to happen automatically, since I need to schedule
      # reboots around others' work:
      #exec { "hold-kernels":
      #  command => "for name in `dpkg --get-selections | grep linux-image | grep -v hold | awk '{print \$1}'`; do echo \$name hold | dpkg --set-selections; done",
      #  onlyif  => "dpkg --get-selections | grep linux-image | grep -q install"
      #}

      file {
        "${apt_dir}/sources.list":
	  checksum => md5,
 	  owner    => root,
	  group	   => root,
          mode 	   => 644,
	  source => "puppet:///etc/apt/sources.list",
	  notify   => Exec["apt-update"];
      }
    }
    default: {
      err("apt_defaults class is for Debian-derived systems.")
      err("${fqdn} runs ${operatingsystem}.")
    }
  }
}

